package com.manager.base;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import org.hibernate.LockMode;
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
import org.springframework.jdbc.core.PreparedStatementCallback;
import org.springframework.jdbc.core.PreparedStatementCreator;
import org.springframework.jdbc.support.KeyHolder;

public interface BaseDao {
	/**
	 * ----------------------------------JDBCTemplate方法----------------------------------
	 */
	public List queryList(String sql);
	public List queryList(String sql, Object... params);
	
	public int queryInt(String sql);
	public int queryInt(String sql, Object... params);
	
	public void add(String sql);
	public void add(String sql, Object... params);
	public int add(PreparedStatementCreator psc, KeyHolder keyHolder);
	
	public void delete(String sql);
	public void delete(String sql, Object... params);
	
	public void update(String sql);
	public void update(String sql, Object... params);
	
	//下面的这两个方法可以通用于批量的add, delete, update
	public int executeBatch(String[] sqls);
	public int executeBatch(String sql, BatchPreparedStatementSetter pss);
	
	//Issue a single SQL execute, typically a DDL statement
	public void execute(String sql);
	
	//call a Stored procedure, return a List<LinkedHashMap>
	public List callProList(String proName, Object ... params);
	
	/**
	 * ----------------------------------HibernateTemplate方法----------------------------------
	 */
	public <T> T get(Class<T> entityClass, Serializable id);
	public <T> T get(Class<T> entityClass, Serializable id, LockMode lockMode);
	public List getList(String hql);
	public List getList(String hql, Object... params);
	public List getListTop(String hql, int length);
	public List getListPage(String hql, int offset, int length);
	public List getListBySql(String sql);
	
	public void save(Object entity);
	public void saveOrUpdateAll(Collection entities);
	
	public void delete(Object entity);
	public void delete(Class entityClass, Serializable id);
	public void deleteAll(Collection entities);
	
	public void update(Object entity);
}
